package com.axun.ckz.yytmanager.base;

import android.content.Context;
import android.text.TextUtils;

import com.axun.ckz.yytmanager.util.UserShare;


/**
 * Created by ckz on 2018/4/23.
 */

public class IBasePresenter {
    Context context;
    IBaseView mView;
    IBaseModule module;

    public IBasePresenter(Context context,IBaseView mView) {
        this.context = context;
        this.mView = mView;
        module = new IBaseXm(context);
    }

    protected void saveUser(String userId,String name,int accountId,String sessionId){
        module.saveUserInfo(userId,name,accountId,sessionId);
    }

    protected void showProgress(String progress){
        if (mView!=null){
            mView.showProgress(progress);
        }
    }

    protected boolean isLogin(){

        return !TextUtils.isEmpty(UserShare.getInstance(context).getUserId());
    }

    protected void hideDialog(){
        if (mView!=null){
            mView.hideProgress();
        }
    }

    protected void showUI(String json){
        if (mView!=null){
            mView.showUI(json);
        }
    }

    protected void showError(String error){
        if (mView!=null){
            mView.showError(error);
        }
    }

    protected void showFaild(String msg){
        if (mView!=null){
            mView.showFaild(msg);
        }
    }
}
